<template>
	<view class="Coupon" :class="{'u-margin-bottom-60' : islast }">
		<view class="left">
			<view class="sum">
				<text class="num">vip</text>
			</view>
			<view class="type u-margin-top-10">¥ {{item.price}}</view>
		</view>
		<view class="right">
			<view class="top">
				<view class="title u-flex-col">
					<text class="tag">兑换码</text>
					<text class="code oneLine-noWrap u-margin-top-10 u-font-22">{{item.code}}</text>
				</view>
				<view class="bottom">
					<view class="date u-line-1" v-if="item.status * 1 !== 0">使用时间 {{item.status_time}}</view>
					<view class="date u-line-1" v-if="item.status * 1 == 0"></view>
					<view class="immediate-use" v-if="item.status * 1 !== 0"> 已使用 </view>
					<view class="immediate-use" v-if="item.status * 1 == 0" @click="copy(item)">立即使用</view>
				</view>
			</view>
			<view class="tips">
				<view class="explain" v-if="item.status * 1 == 0">
					<u-icon name="zhuanfa" class="transpond" :size="24"></u-icon>
					<text>可赠送</text>
				</view>
				<view class="explain" v-else>
					<u-icon name="zhuanfa" class="transpond" :size="24"></u-icon>
					<text>已使用</text>
				</view>
			</view>
		</view>
	</view>


</template>

<script>
	export default {
		name: 'Coupon',
		data() {
			return {

			}
		},
		methods: {
			copy(item) {
				uni.setClipboardData({
					data: item.code,
					success: res => {
						uni.showModal({
							title: '提示',
							content: '已复制,分享给朋友吧',
							success: r => {

							}
						});
					}
				});
			}
		},
		props: {
			item: {
				type: Object,
				default: () => {}
			},
			islast: {
				type: Boolean,
				default: false,
			}
		}
	}
</script>

<style scoped lang="scss">
	.Coupon {
		margin-top: 40rpx;
		width: 700rpx;
		height: auto;
		background-color: #FFFFFF;
		display: flex;
		border-radius: 30rpx;
		overflow: hidden;
		box-shadow: 0rpx 0rpx 14rpx 0rpx #999;

		.code {
			width: 400rpx;
			display: block;
		}

		.left {
			padding: 0 30rpx;
			background-color: rgb(95, 148, 224); //rgb(94, 152, 225);
			text-align: center;
			font-size: 28rpx;
			color: #ffffff;
			width: 200rpx;

			.sum {
				margin-top: 50rpx;
				font-weight: bold;
				font-size: 32rpx;

				.num {
					font-size: 70rpx;
				}
			}

			.type {
				margin-bottom: 50rpx;
				font-size: 24rpx;
			}
		}

		.right {
			padding: 20rpx 20rpx 0;
			font-size: 28rpx;

			.top {
				border-bottom: 2rpx dashed $u-border-color;

				.title {
					margin-right: 60rpx;
					line-height: 40rpx;

					.tag {
						padding: 4rpx 20rpx;
						background-color: rgb(73, 154, 201);
						border-radius: 20rpx;
						color: #ffffff;
						font-weight: bold;
						font-size: 24rpx;
						margin-right: 10rpx;
						width: 120rpx;
						text-align: center;
					}
				}

				.bottom {
					display: flex;
					margin-top: 20rpx;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 10rpx;

					.date {
						font-size: 22rpx;
						flex: 1;
					}

					.immediate-use {
						height: auto;
						padding: 0 20rpx;
						font-size: 24rpx;
						border-radius: 40rpx;
						line-height: 40rpx;
						color: rgb(117, 142, 165);
						border: 2rpx solid rgb(117, 142, 165);
					}
				}
			}

			.tips {
				width: 100%;
				line-height: 50rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;

				.transpond {
					margin-right: 10rpx;
				}

				.explain {
					display: flex;
					align-items: center;
				}

				.particulars {
					width: 30rpx;
					height: 30rpx;
					box-sizing: border-box;
					padding-top: 8rpx;
					border-radius: 50%;
					background-color: $u-type-info-disabled;
					text-align: center;
				}
			}
		}
	}
</style>
